{% extends 'users/usercenter-base.html' %}
{% load static %}
{% block title %}
    我的收藏- 谷粒教育网
{% endblock %}
{% block breach %}
    我的收藏
{% endblock %}
{% block right %}
    <div class="right">
        <div class="personal_des Releasecont">
            <div class="head">
                <h1>我的收藏</h1>
            </div>

        </div>
        <div class="personal_des permessage">
            <div class="head">
                <ul class="tab_header messagehead">
                    <li class="active"><a href="{% url 'users:user_loveorg' %}">课程机构</a></li>
                    <li><a href="{% url 'users:user_loveteacher' %}">授课教师 </a></li>
                    <li><a href="{% url 'users:user_lovecourse' %}">公开课程</a></li>
                </ul>
            </div>
            <div class="messagelist">
                {% for org in org_list %}
                    <div class="messages butler_list company company-fav-box">

                    <dl class="des fr">
                        <dt>
                            <a href="{% url 'orgs:org_detail' org.id %}">
                                <img width="160" height="90" src="{{ MEDIA_URL }}{{ org.image }}"/>
                            </a>
                        </dt>
                        <dd>
                            <h1><a href="{% url 'orgs:org_detail' org.id %}">{{ org.name }}</a></h1>
                            <div class="pic fl" style="width:auto;">

                                <img src="{% static 'images/authentication.png' %}"/>


                                <img src="{% static 'images/gold.png' %}"/>

                            </div>
                            <span class="c8 clear">{{ org.address }}</span>
                            <div class="delete jsDeleteFav_org" data-favid="{{ org.id }}"></div>
                        </dd>
                    </dl>
                </div>
                {% endfor %}
            </div>
        </div>
    </div>
{% endblock %}
{% block user %}
{% endblock %}
{% block myjs1 %}
    <script>
        $(function () {
            $(".delete").click(function () {
                {# this代表当前点击的事件      prop()取天生就有的属性或设置值 attr()取自定义属性或设置值  #}
                var loveid = $(this).attr("data-favid");
                var lovetype = 1;
                {# 这个this坑很多 #}
                var obj = $(this);
                $.ajax({
                    type: "GET",
                    url: "{% url 'operations:user_deletelove' %}",
                    data: {
                        loveid: loveid,
                        lovetype: lovetype
                    },
                    success: function (callback) {
                        if (callback.status == "ok") {
                            alert(callback.msg);
                            {#  拿到点击对象的祖先节点当中有类名是des的对象  #}
                            obj.parents(".messages").remove();
                        } else {
                            alert(callback.msg);
                        }
                    }
                });
            });
        });
    </script>
{% endblock %}
